package com.hemi.rhet.js;

import java.io.InputStream;
import java.util.HashMap;

import org.apache.http.util.EncodingUtils;

import android.app.Activity;

public class JavaScriptUtil {
	private static HashMap<String, String> contentMap = new HashMap();
	public static String getJsContentFromFile(Activity act, String fileName) {
		if (contentMap.get(fileName) != null) {
//			return contentMap.get(fileName);
		}
		String res = "";
		try {
			InputStream in = act.getResources().getAssets().open(fileName);
			int length = in.available();
			byte[] buffer = new byte[length];
			in.read(buffer);
			res = EncodingUtils.getString(buffer, "UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}
		contentMap.put(fileName, res);
		return res;
	}
}
